package com.feicheng.lanniao.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * @Author tianchunlei
 * @Des //读取消息配置文件的工具类
 * @Date 2021/7/7
 **/
public class ReadPropertiesUtil {

    /**
     * @return 返回Properties对象
     * @Author tianchunlei
     * @Description //获取消息配置参数的方法
     * @Date 2021/7/7 13:15
     * @Param 文件路径
     */
    public static Properties getProperties(String propertiesPath) {
        Properties properties = new Properties();
        try {
            //通过IO流方式读取配置文件
            InputStream inputStream = com.feicheng.lanniao.util.ReadPropertiesUtil.class.getResourceAsStream( propertiesPath );
            BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
            properties.load(bf);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return properties;
    }


    /**
     * @Author tianchunlei
     * @Description //测试getProperties方法
     * @Date 2021/7/7 13:16
     * @Param
     * @return
     */
//    @Test
//    public void getPropertiesTest() {
//        //获取程序当前路径下的文件
//        Properties properties = com.feicheng.lanniao.util.ReadPropertiesUtil
//                .getProperties("/responseMessage.properties");
//    }
}
